package research.sbookmarking.input;

import java.util.*;

import org.connotea.*;

//import java.util.Random;


public class RandomUserCommand extends BookmarkCommand {

	private int loop = 1;
	
	public RandomUserCommand(String name, String className,
			   String command, List param, 
			   Integer start, Integer limit, Integer times,
			   Integer user) {
		
		super(name, className,command, param, start, limit, times);
		
		this.loop = user.intValue();
	}

	
	/* (non-Javadoc)
	 * @see research.sbookmarking.input.BookmarkCommand#execute()
	 */
	public void execute() {
		// get list of bookmarks
		super.execute();
		// get list of users
		ArrayList users = new ArrayList();
		Iterator items = ((List)getResult()).iterator();
		while (items.hasNext()){
			Object item = items.next();
			if (users.contains(item)) {
				users.add(item);		
			}
		}
		
		ArrayList data = new ArrayList();
		Random random = new Random();
		
		try {
			Connotea database = new Connotea ("alby1976","a1014leung");
			ArrayList results = new ArrayList();
			for (int count=0; count <= this.loop;count++){
				//String user =(String)((List)getResult()).get(random.nextInt(users.size()));
				data.add(database.getPosts(""));
			}
			//setResult(data);
		}
		catch (ConnoteaException e){
			System.err.println(e.getMessage());
			System.exit(-1);
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
